package com.ebook.eboo.Service;

import com.ebook.eboo.Dao.bookDAO;
import com.ebook.eboo.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class bookService {
    @Autowired
    bookDAO bookDAO;

    public Book save(Book book){
        return bookDAO.save(book);
    }

    public List<Book> getAll(){
        return bookDAO.getAllBy();
    }
    public List<Book> getByType(String type){
        return bookDAO.getAllByType(type);
    }
    public Book getByTitle(String title){
        return bookDAO.getByTitle(title);
    }
    public void deleteByTitle(String title){
        bookDAO.deleteBookByTitle(title);
    }
    public int updateById(Book book){
        return bookDAO.updateById(book.getTitle(),book.getAuthor(),book.getType(),book.getPress(),book.getId());
    }
}
